<template>
	<view class="">
		<citys  :city-list="cityList" @select="handleCitySelect" />
	</view>
</template>

<script setup>
	import { ref } from 'vue';
	import { onShow , onLoad , onReachBottom } from '@dcloudio/uni-app';
	import { apiCitys } from '@/api/upapi.js';
	import citys from '@/components/citys.vue'
	
	const cityList = ref([])
	
	const cityData = async (e) => {
		try {
			let res = await apiCitys({});
			cityList.value=res.data
		} catch (error) {
			console.error('获取数据失败', error);
		}
	};
	const handleCitySelect = (city) => {
		console.log('选中城市:', city)
		const citynames=city.name+'市';
		
		uni.setStorageSync('cityName', citynames);
		uni.setStorageSync('cityIds', city.cityId);
		uni.navigateBack()
	}
	
	onLoad(() => {
		cityData();
	});
</script>

<style scoped lang="scss">
</style>